package com.kly.module_base.base

import android.os.Bundle
import android.view.LayoutInflater
import androidx.lifecycle.ViewModelProvider
import androidx.viewbinding.ViewBinding

abstract class BaseCommonActivity<VB : ViewBinding, VM : BaseViewModel>(val inflaterBlock: (LayoutInflater) -> VB, private val modelClass: Class<VM>) : BaseActivity() {
    val binding: VB by lazy { inflaterBlock(layoutInflater) }
    var mViewModel: VM? = null

    override fun beforeOnCreate(savedInstanceState: Bundle?) {
        super.beforeOnCreate(savedInstanceState)
        mViewModel = ViewModelProvider(this)[modelClass]
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(binding.root)
        initView()
        initData()
        initListener()
    }

    open fun initListener() {

    }

    open fun initView() {

    }

    abstract fun initData()
}